<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!--第1步引入vue.js文件--> 
    <script src="../vue.js"></script>
    <style>
        .mystyle{
            width: 100px;
            height: 100px;
            background-color: teal;
            margin: 20px;
        }
        .youstyle{
            width: 100px;
            height: 100px;
            background-color:red;
            margin: 20px;
        }
    </style>
</head>
<body>
    <!--第2步：在body中定义一个div层-->
    <div id="app">
       <button @click="addCls">添加样式</button><br>
       <button @click="changePic">改变图片</button>
       <div v-bind:class="classA"></div>
       <img :src="imgPath">
    </div>

</body>
</html>
<script>
    //第3步：创建vue实例
    var vm=new Vue({ 
        el:'#app', //选择器
        data:{
           classA:'',
           imgPath:'../images/userface2.jpg'
        },
        methods:{
            addCls:function(){
                this.classA='youstyle';
            },
            changePic:function(){
                this.imgPath='../images/userface1.jpg';
            }
        }
    });
</script> 